var Connect = YAHOO.util.Connect,
        Dom = YAHOO.util.Dom,
        Json = YAHOO.lang.JSON;

var UserController = {
    asyncRequestFalse: function() {
        alert('AsyncRequest False');
    },
    userLogin: function() {
        var height = Dom.getDocumentHeight();
        Dom.removeClass('overlay', 'hide');
        Dom.setStyle('overlay', 'height', height + 'px');
        Dom.addClass('overlay', 'show');
        var strUrl = serverUrl + '/user-ajax/dang-nhap';
        Connect.setForm('frmUserLogin');
        Connect.asyncRequest('POST', strUrl, {
            success: this.userLoginSuccess,
            failure: this.asyncRequestFalse
        });
        Connect.resetFormState();
    },
    userLoginSuccess: function(xmlhttp) {
        var strData = xmlhttp.responseText;
//        var aryData = Json.parse(strData);
        Dom.removeClass('overlay', 'show');
        Dom.addClass('overlay', 'hide');
        Dom.get('user-login-form').innerHTML = strData;
    },
    userRegister: function() {
        var height = Dom.getDocumentHeight();
        Dom.removeClass('overlay', 'hide');
        Dom.setStyle('overlay', 'height', height + 'px');
        Dom.addClass('overlay', 'show');
        var strUrl = serverUrl + '/user-ajax/dang-ky';
        Connect.setForm('frmUserRegister');
        Connect.asyncRequest('POST', strUrl, {
            success: this.userRegisterSuccess,
            failure: this.asyncRequestFalse
        });
        Connect.resetFormState();
    },
    userRegisterSuccess: function(xmlhttp) {
        var strData = xmlhttp.responseText;
//        var aryData = Json.parse(strData);
        Dom.removeClass('overlay', 'show');
        Dom.addClass('overlay', 'hide');
        Dom.get('user-register').innerHTML = strData;
    }
};